/*
=======================================================================

  BOTS Main Menu

=======================================================================
*/

#include "ui_local.h"
#include "ui_BOTS.h"

#define BOTS_TEAMCOMMANDSMENU_AUTOID		1
#define BOTS_TEAMCOMMANDSMENU_DROPFLAG		2
#define BOTS_TEAMCOMMANDSMENU_IMPEACH		3
#define BOTS_TEAMCOMMANDSMENU_LOCATEPROMO	5
#define BOTS_TEAMCOMMANDSMENU_LOCATETECH	6
#define BOTS_TEAMCOMMANDSMENU_PLAYERID		9
#define BOTS_TEAMCOMMANDSMENU_REJOIN		10
#define BOTS_TEAMCOMMANDSMENU_CHANGECLASS	12

typedef struct 
{
  menuframework_s menu;  

  menutext_s	title;
  menutext_s	autoid;
  menutext_s	dropflag;
  menutext_s	impeach;
  menutext_s	locatepromo;
  menutext_s	locatetech;
  menutext_s	playerid;
  menutext_s	rejoin;
  menutext_s	changeclass;
  menutext_s	cancel;
} BOTSTeamCommandsMenu_t;

BOTSTeamCommandsMenu_t s_BOTSTeamCommandsMenu;

/*
=================
BOTS_TeamCommandsMenu_Event
callback routine
=================
*/
void BOTS_TeamCommandsMenu_Event( void *ptr, int notification ) 
{
	if( notification != QM_ACTIVATED )
		return;

	// any event will kill the menu
	UI_PopMenu();

	switch( ((menucommon_s*)ptr)->id ) 
	{
	case BOTS_CANCEL:
		break;
	case BOTS_TEAMCOMMANDSMENU_AUTOID:
		trap_Cmd_ExecuteText( EXEC_APPEND, "autoid\n" );
		break;
	case BOTS_TEAMCOMMANDSMENU_DROPFLAG:
		trap_Cmd_ExecuteText( EXEC_APPEND, "dropflag\n" );
		break;
	case BOTS_TEAMCOMMANDSMENU_IMPEACH:
		trap_Cmd_ExecuteText( EXEC_APPEND, "impeach\n" );
		break;
	case BOTS_TEAMCOMMANDSMENU_LOCATEPROMO:
		trap_Cmd_ExecuteText( EXEC_APPEND, "locatepromo\n" );
		break;
	case BOTS_TEAMCOMMANDSMENU_LOCATETECH:
		trap_Cmd_ExecuteText( EXEC_APPEND, "locatetech\n" );
		break;
	case BOTS_TEAMCOMMANDSMENU_PLAYERID:
		trap_Cmd_ExecuteText( EXEC_APPEND, "playerid\n" );
		break;
	case BOTS_TEAMCOMMANDSMENU_REJOIN:
		BOTS_TeamJoinMenu_f();
		break;
	case BOTS_TEAMCOMMANDSMENU_CHANGECLASS:
		BOTS_ClassJoinMenu_f();
		break;
	// oops - not a valid choice
	default:
		Com_Printf("%i is not a valid choice\n", ((menucommon_s*)ptr)->id);
		break;
	} 
}


/*
=================
BOTS_TeamCommandsMenu_Init
=================
*/
void BOTS_TeamCommandsMenu_Init() 
{
	int		y;

	memset( &s_BOTSTeamCommandsMenu, 0 ,sizeof(BOTSTeamCommandsMenu_t) );
	s_BOTSTeamCommandsMenu.menu.wrapAround = qtrue;
	s_BOTSTeamCommandsMenu.menu.fullscreen = qfalse;

	y = 96;
	s_BOTSTeamCommandsMenu.title.generic.type		= MTYPE_PTEXT;
	s_BOTSTeamCommandsMenu.title.generic.flags		= QMF_CENTER_JUSTIFY;
	s_BOTSTeamCommandsMenu.title.generic.x			= 320;
	s_BOTSTeamCommandsMenu.title.generic.y			= y;
	s_BOTSTeamCommandsMenu.title.string				= "Team Commands Menu";
	s_BOTSTeamCommandsMenu.title.color				= color_bots_menu;
	s_BOTSTeamCommandsMenu.title.style				= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;
/*
	y += BOTS_VERTICAL_SPACING;
	s_BOTSTeamCommandsMenu.autoid.generic.type		= MTYPE_PTEXT;
	s_BOTSTeamCommandsMenu.autoid.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSTeamCommandsMenu.autoid.generic.x			= 320;
	s_BOTSTeamCommandsMenu.autoid.generic.y			= y;
	s_BOTSTeamCommandsMenu.autoid.generic.id		= BOTS_TEAMCOMMANDSMENU_AUTOID;
	s_BOTSTeamCommandsMenu.autoid.generic.callback	= BOTS_TeamCommandsMenu_Event; 
	s_BOTSTeamCommandsMenu.autoid.string			= "TOGGLE AUTOID - autoid";
	s_BOTSTeamCommandsMenu.autoid.color				= color_bots_menu;
	s_BOTSTeamCommandsMenu.autoid.style				= UI_CENTER|UI_SMALLFONT;
*/
	y += BOTS_VERTICAL_SPACING;
	s_BOTSTeamCommandsMenu.dropflag.generic.type		= MTYPE_PTEXT;
	s_BOTSTeamCommandsMenu.dropflag.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSTeamCommandsMenu.dropflag.generic.x			= 320;
	s_BOTSTeamCommandsMenu.dropflag.generic.y			= y;
	s_BOTSTeamCommandsMenu.dropflag.generic.id			= BOTS_TEAMCOMMANDSMENU_DROPFLAG;
	s_BOTSTeamCommandsMenu.dropflag.generic.callback	= BOTS_TeamCommandsMenu_Event; 
	s_BOTSTeamCommandsMenu.dropflag.string				= "DROP THE FLAG - dropflag";
	s_BOTSTeamCommandsMenu.dropflag.color				= color_bots_menu;
	s_BOTSTeamCommandsMenu.dropflag.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSTeamCommandsMenu.impeach.generic.type		= MTYPE_PTEXT;
	s_BOTSTeamCommandsMenu.impeach.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSTeamCommandsMenu.impeach.generic.x		= 320;
	s_BOTSTeamCommandsMenu.impeach.generic.y		= y;
	s_BOTSTeamCommandsMenu.impeach.generic.id		= BOTS_TEAMCOMMANDSMENU_IMPEACH;
	s_BOTSTeamCommandsMenu.impeach.generic.callback	= BOTS_TeamCommandsMenu_Event; 
	s_BOTSTeamCommandsMenu.impeach.string			= "IMPEACH CAPTAIN - impeach";
	s_BOTSTeamCommandsMenu.impeach.color			= color_bots_menu;
	s_BOTSTeamCommandsMenu.impeach.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSTeamCommandsMenu.locatepromo.generic.type		= MTYPE_PTEXT;
	s_BOTSTeamCommandsMenu.locatepromo.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSTeamCommandsMenu.locatepromo.generic.x		= 320;
	s_BOTSTeamCommandsMenu.locatepromo.generic.y		= y;
	s_BOTSTeamCommandsMenu.locatepromo.generic.id		= BOTS_TEAMCOMMANDSMENU_LOCATEPROMO;
	s_BOTSTeamCommandsMenu.locatepromo.generic.callback	= BOTS_TeamCommandsMenu_Event; 
	s_BOTSTeamCommandsMenu.locatepromo.string			= "LOCATE PROMOTION KEY - locatepromo";
	s_BOTSTeamCommandsMenu.locatepromo.color			= color_bots_menu;
	s_BOTSTeamCommandsMenu.locatepromo.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSTeamCommandsMenu.locatetech.generic.type		= MTYPE_PTEXT;
	s_BOTSTeamCommandsMenu.locatetech.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSTeamCommandsMenu.locatetech.generic.x			= 320;
	s_BOTSTeamCommandsMenu.locatetech.generic.y			= y;
	s_BOTSTeamCommandsMenu.locatetech.generic.id		= BOTS_TEAMCOMMANDSMENU_LOCATETECH;
	s_BOTSTeamCommandsMenu.locatetech.generic.callback	= BOTS_TeamCommandsMenu_Event; 
	s_BOTSTeamCommandsMenu.locatetech.string			= "LOCATE THE TECH KEY - locatetech";
	s_BOTSTeamCommandsMenu.locatetech.color				= color_bots_menu;
	s_BOTSTeamCommandsMenu.locatetech.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSTeamCommandsMenu.playerid.generic.type		= MTYPE_PTEXT;
	s_BOTSTeamCommandsMenu.playerid.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSTeamCommandsMenu.playerid.generic.x			= 320;
	s_BOTSTeamCommandsMenu.playerid.generic.y			= y;
	s_BOTSTeamCommandsMenu.playerid.generic.id			= BOTS_TEAMCOMMANDSMENU_PLAYERID;
	s_BOTSTeamCommandsMenu.playerid.generic.callback	= BOTS_TeamCommandsMenu_Event; 
	s_BOTSTeamCommandsMenu.playerid.string				= "PLAYER STATUS - playerid";
	s_BOTSTeamCommandsMenu.playerid.color				= color_bots_menu;
	s_BOTSTeamCommandsMenu.playerid.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSTeamCommandsMenu.rejoin.generic.type		= MTYPE_PTEXT;
	s_BOTSTeamCommandsMenu.rejoin.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSTeamCommandsMenu.rejoin.generic.x			= 320;
	s_BOTSTeamCommandsMenu.rejoin.generic.y			= y;
	s_BOTSTeamCommandsMenu.rejoin.generic.id		= BOTS_TEAMCOMMANDSMENU_REJOIN;
	s_BOTSTeamCommandsMenu.rejoin.generic.callback	= BOTS_TeamCommandsMenu_Event; 
	s_BOTSTeamCommandsMenu.rejoin.string			= "SELECT A NEW TEAM - rejoin";
	s_BOTSTeamCommandsMenu.rejoin.color				= color_bots_menu;
	s_BOTSTeamCommandsMenu.rejoin.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSTeamCommandsMenu.changeclass.generic.type		= MTYPE_PTEXT;
	s_BOTSTeamCommandsMenu.changeclass.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSTeamCommandsMenu.changeclass.generic.x		= 320;
	s_BOTSTeamCommandsMenu.changeclass.generic.y		= y;
	s_BOTSTeamCommandsMenu.changeclass.generic.id		= BOTS_TEAMCOMMANDSMENU_CHANGECLASS;
	s_BOTSTeamCommandsMenu.changeclass.generic.callback	= BOTS_TeamCommandsMenu_Event; 
	s_BOTSTeamCommandsMenu.changeclass.string			= "CLASS MENU - changeclass";
	s_BOTSTeamCommandsMenu.changeclass.color			= color_bots_menu;
	s_BOTSTeamCommandsMenu.changeclass.style			= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSTeamCommandsMenu.cancel.generic.type		= MTYPE_PTEXT;
	s_BOTSTeamCommandsMenu.cancel.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSTeamCommandsMenu.cancel.generic.x			= 320;
	s_BOTSTeamCommandsMenu.cancel.generic.y			= y;
	s_BOTSTeamCommandsMenu.cancel.generic.id		= BOTS_CANCEL;
	s_BOTSTeamCommandsMenu.cancel.generic.callback	= BOTS_TeamCommandsMenu_Event; 
	s_BOTSTeamCommandsMenu.cancel.string			= "CANCEL";
	s_BOTSTeamCommandsMenu.cancel.color				= color_bots_menu;
	s_BOTSTeamCommandsMenu.cancel.style				= UI_CENTER|UI_SMALLFONT;
	
	Menu_AddItem( &s_BOTSTeamCommandsMenu.menu, &s_BOTSTeamCommandsMenu.title );
//	Menu_AddItem( &s_BOTSTeamCommandsMenu.menu, &s_BOTSTeamCommandsMenu.autoid );
	Menu_AddItem( &s_BOTSTeamCommandsMenu.menu, &s_BOTSTeamCommandsMenu.dropflag );
	Menu_AddItem( &s_BOTSTeamCommandsMenu.menu, &s_BOTSTeamCommandsMenu.impeach );
	Menu_AddItem( &s_BOTSTeamCommandsMenu.menu, &s_BOTSTeamCommandsMenu.locatepromo );
	Menu_AddItem( &s_BOTSTeamCommandsMenu.menu, &s_BOTSTeamCommandsMenu.locatetech );
	Menu_AddItem( &s_BOTSTeamCommandsMenu.menu, &s_BOTSTeamCommandsMenu.playerid );
	Menu_AddItem( &s_BOTSTeamCommandsMenu.menu, &s_BOTSTeamCommandsMenu.rejoin );
	Menu_AddItem( &s_BOTSTeamCommandsMenu.menu, &s_BOTSTeamCommandsMenu.changeclass );
	Menu_AddItem( &s_BOTSTeamCommandsMenu.menu, &s_BOTSTeamCommandsMenu.cancel );
}

/*
=================
BOTS_TeamCommandsMenu_f
=================
*/
void BOTS_TeamCommandsMenu_f(void) 
{
	// force as top level menu
	uis.menusp = 0;  

	// set menu cursor to a nice location
	uis.cursorx = 319;
	uis.cursory = 80;

	// setup the menu structure
	BOTS_TeamCommandsMenu_Init();

	// show the menu
	UI_PushMenu( &s_BOTSTeamCommandsMenu.menu );
}
